#ifndef __ALTCP_TLS_HITLS_H__
#define __ALTCP_TLS_HITLS_H__

#include "lwip/opt.h"
#include "altcp_tls_hitls_opts.h"

/* Forward declaration */
struct altcp_tls_config;

#if defined(LWIP_ALTCP) && defined(LWIP_ALTCP_TLS_HITLS)

#include "lwip/altcp.h"

#ifdef __cplusplus
extern "C" {
#endif

#ifdef LWIP_ALTCP_HITLS_PROVIDER
/**
 * @brief Set HiTLS provider library information
 * @param libCtx lib context
 * @param attr provider attributes
 * 
 * @note Non-thread safe, only call once during initialization
 */
void altcp_hitls_init(void *libCtx, const char *attr);

void altcp_hitls_deinit(void);
#endif

struct altcp_pcb *altcp_tls_new(struct altcp_tls_config *config, uint8_t ip_type);

struct altcp_pcb *altcp_tls_alloc(void *arg, uint8_t ip_type);

void altcp_tls_free_config(struct altcp_tls_config *conf);

struct altcp_tls_config *altcp_tls_create_config_server_privkey_cert(const uint8_t *privkey, size_t privkey_len,
    const uint8_t *privkey_pass, size_t privkey_pass_len, const uint8_t *cert, size_t cert_len);

struct altcp_tls_config *altcp_tls_create_config_client(const uint8_t *ca, size_t ca_len
#ifdef LWIP_ALTCP_HITLS_AUTH_MODE
    , uint8_t isAuth
#endif
);

struct altcp_tls_config *altcp_tls_create_config_client_2wayauth(const uint8_t *ca, size_t ca_len, const uint8_t *privkey, size_t privkey_len,
    const uint8_t *privkey_pass, size_t privkey_pass_len, const uint8_t *cert, size_t cert_len
#ifdef LWIP_ALTCP_HITLS_CRL
    , const uint8_t *crl, size_t crl_len
#endif
#ifdef LWIP_ALTCP_HITLS_AUTH_MODE
    , uint8_t isAuth
#endif
);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* LWIP_ALTCP && LWIP_ALTCP_TLS_HITLS */

#endif /* __ALTCP_TLS_HITLS_H__ */